package com.base.social.domain;

import java.io.Serializable;

/**
 * 授权回调时的参数类
 *
 * @author becker
 * @since 0.0.1
 */
public class AuthCallbackParams implements Serializable {

    /**
     * 访问AuthorizeUrl后回调时带的参数code
     */
    private String code;

    /**
     * 访问AuthorizeUrl后回调时带的参数auth_code，该参数目前只使用于支付宝登录
     */
    private String authCode;

    /**
     * 访问AuthorizeUrl后回调时带的参数state，用于和请求AuthorizeUrl前的state比较，防止CSRF攻击
     */
    private String state;

    /**
     * 华为授权登录接受code的参数名
     *
     * @since 1.10.0
     */
    private String authorizationCode;


    public AuthCallbackParams(String code, String authCode, String state, String authorizationCode) {
        this.code = code;
        this.authCode = authCode;
        this.state = state;
        this.authorizationCode = authorizationCode;
    }

    public AuthCallbackParams() {
    }

    public static AuthCallbackParamsBuilder builder() {
        return new AuthCallbackParamsBuilder();
    }

    public String getCode() {
        return this.code;
    }

    public String getAuthCode() {
        return this.authCode;
    }

    public String getState() {
        return this.state;
    }

    public String getAuthorizationCode() {
        return this.authorizationCode;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setAuthCode(String authCode) {
        this.authCode = authCode;
    }

    public void setState(String state) {
        this.state = state;
    }

    public void setAuthorizationCode(String authorizationCode) {
        this.authorizationCode = authorizationCode;
    }

    public static class AuthCallbackParamsBuilder {
        private String code;
        private String authCode;
        private String state;
        private String authorizationCode;

        AuthCallbackParamsBuilder() {
        }

        public AuthCallbackParams.AuthCallbackParamsBuilder code(String code) {
            this.code = code;
            return this;
        }

        public AuthCallbackParams.AuthCallbackParamsBuilder authCode(String authCode) {
            this.authCode = authCode;
            return this;
        }

        public AuthCallbackParams.AuthCallbackParamsBuilder state(String state) {
            this.state = state;
            return this;
        }

        public AuthCallbackParams.AuthCallbackParamsBuilder authorizationCode(String authorizationCode) {
            this.authorizationCode = authorizationCode;
            return this;
        }


        public AuthCallbackParams build() {
            return new AuthCallbackParams(code, authCode, state, authorizationCode);
        }

        public String toString() {
            return "AuthCallbackParams.AuthCallbackParamsBuilder(code=" + this.code + ", authCode=" + this.authCode + ", state=" + this.state + ", authorizationCode=" + this.authorizationCode + ")";
        }
    }
}
